Deavmi's coding shack
Commit dbb425ced0c206b8520ece43c4a8d41bc2f36806
Parents : 724f502
Author : Tristan Brice Velloza Kildaire <deavmi@redxen.eu>
Date : 2026-02-03T17:14:16+02:00
StdLogger (tests)
- Enabled part of the testing
Changes
Diff
diff --git a/std/logger/basic_test.go b/std/logger/basic_test.go
index 898a799..38fc0be 100644
--- a/std/logger/basic_test.go
+++ b/std/logger/basic_test.go
@@ -1,10 +1,77 @@
package logger;
+import "new.git.deavmi.assigned.network/deavmi/glog.git/record";
import "testing";
-import "time";
+// import "time";
+import "new.git.deavmi.assigned.network/deavmi/glog.git/std/consts";
+import "fmt";
+
+type InspectorAppender struct {
+ // TODO: Make this safe
+ _lrs []record.LogRecord
+}
+
+func (ia *InspectorAppender) Do(lr record.LogRecord) error {
+ ia._lrs = append(ia._lrs, lr)
+ return nil
+}
func TestBasic(t *testing.T) {
var sl = NewStdLogger("testing logger")
+ var ia = InspectorAppender{}
+ sl.AddAppender(&ia)
+
+ fmt.Printf("----\n")
+
+
+ sl.Fatal("*** A Fatality ***")
+ sl.Info("*** B NeverInformative 1 ***")
+
+ sl.SetLevel(consts.LEVEL_INFO)
+
+ // sl.Info("*** B NeverInformative 2 ***")
+
+ // Set logging level to INFO
+ // sl.DebugHandlers()
+ // sl.SetLevel(consts.LEVEL_ERROR)
+ // fmt.Printf("Me rn: %v\n", sl.levelFilter)
+ // sl.DebugHandlers()
+ // sl.SetLevel(consts.LEVEL_INFO)
+
+ // Logging level is INFO, hence all
+ // four should make it in
+ // FIXME: Re-enable
+ // sl.Info("Hello %s, the time is currently %v", "Tristan", time.Now())
+ // sl.Warn("Warning")
+ // sl.Error("Error")
+ // sl.Fatal("Fatal")
+
+ // FIXME: Re-enable
+ // But anything beneath INFO (DEBUG and TRACE)
+ // should not be logged
+ // sl.Debug("Debug")
+ // sl.Trace("Trace")
+
+
+ // FIXME: Re-enable
+ // Therefore only 4 messages should have made it in
+ // if len(ia._lrs) != 4 {
+ // t.FailNow();
+ // }
+
+
+ // Set logging level to `DEBUG`
+ // and there should only have
+ // been one message logged
+ sl.SetLevel(consts.LEVEL_DEBUG)
+ ia._lrs = nil
+ sl.Debug("Howdy Debug")
+ sl.Trace("Howdy Trace")
+ if len(ia._lrs) != 1 {
+ t.FailNow();
+ }
- sl.Info("Hello %s, the time is currently %v", "Tristan", time.Now())
+ // Check that we have the right things (TODO: Write my own assertion library smh)
+ // ia._lrs[0]
+ // t.FailNow()
}
Served by rngit 1.5.0 - Generated in 0.08s